package com.right.health.app.net;

import com.magics.http.model.HttpParams;
import com.right.health.app.app.App;

import org.json.JSONException;
import org.json.JSONObject;

/*
 * Created by hopeliao on 2019-11-30
 *
 */public class CertificationApi extends IBaseApi {

    public void addAuthentication(String serverPath, String name, String idcard, String code) {
        HttpParams params = new HttpParams();
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("idcardpic", serverPath);
            jsonObject.put("personid", App.getInstance().getUserId());
            jsonObject.put("syscommunitycode", code);
            jsonObject.put("idcard", idcard);
            jsonObject.put("personname", name);

            params.addFormParam("jsonstr", jsonObject.toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        doPostJson(HttpConstants.API_AUTHENTICATION, params, null);
    }

    public void getVerificationCode(String phone) {
        HttpParams params = new HttpParams();
        params.addFormParam("mobile", phone);

        doPostJson(HttpConstants.API_GETCERTIFICATION_CODE, params, null);
    }

    public void certificationByHospital(String reservedphone, String code, String idcard, String name, String hospitalCode) {
        HttpParams params = new HttpParams();
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("reservedphone", reservedphone);
            jsonObject.put("personid", App.getInstance().getUserId());
            jsonObject.put("code", code);
            jsonObject.put("idcard", idcard);
            jsonObject.put("personname", name);
            jsonObject.put("syscommunitycode", hospitalCode);

            params.addFormParam("jsonstr", jsonObject.toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        doPostJson(HttpConstants.API_ADD_HOSPITAL_AUTH, params, null);
    }
}
